from typing import List


class Solution:
    def numSubarrayProductLessThanK(self, nums: List[int], k: int) -> int:
        a, b = 0, 0

        ans = 0
        now = 1
        while a < len(nums):
            b = max(a, b)
            while b < len(nums) and now * nums[b] < k:
                now *= nums[b]
                b += 1

            ans += b - a

            now //= nums[a]
            a += 1

        return ans


if __name__ == "__main__":
    print(Solution().numSubarrayProductLessThanK(nums=[10, 5, 2, 6], k=100))  # 8
    print(Solution().numSubarrayProductLessThanK(nums=[1, 2, 3], k=0))  # 0
